#ifndef GAMEOBJECT_H
#define GAMEOBJECT_H

#include <string>
#include <vector>
#include "glut.h"
#include <gl\GL.h>


// The parent class of the objects in the game.
class GameObject
{
public:
	enum Type
	{
		Type_Player,
		Type_Monster,
		Type_Door,
		Type_Projectile,
		Type_Room,
		Type_Wall,
		Type_PickUp
	};

	struct drawPoint
	{
		drawPoint(double x, double y, double z) :
			x(x),
			y(y),
			z(z)
		{}

		double x, y, z;
	};

	GameObject(int x, int y, Type type);
	virtual ~GameObject() {}

	// Destroy the object. The actual deletion is delayed till the gameobjectmanager updated
	// all gameobjects.
	void destroy();
	bool isDestroyed() const;

	// This function will call the virtual drawObject function which can be
	// implemented by subclasses to provide different render functionality.
	void draw() const;

	// Pure functional function to determine the render color of the object.
	virtual void setDrawColor() const = 0;

	bool canBePassed(const GameObject* gameObject) const;
	// Implement this function in subclasses to handle collisions.
	virtual void handleCollision(GameObject* gameObject);

	void getLocation(int& xCur, int& yCur) const;
    void setLocation(const int xNew, const int yNew);

	Type getType() const;

protected:
	// Implement this function in subclasses to make it passable/unpassable by other types of objects.
	virtual bool isPassable(const GameObject* gameObject) const;

	static void setColor(float r, float g, float b);
	
	// Parallel to location in map. Saves searching for it.
    int x;
    int y;

	// Implement this function in subclasses to add custom render functionality.
	virtual void drawObject(int row, int col) const;
	void drawInMode(GLenum mode, const std::vector<drawPoint>& points) const;
	void drawSquare(int row, int col) const;

private:
	bool destroyed;
	Type type;
};

#endif